package algorithm_optimal_solution.LinkedList;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

//反转部分单向链表：找到from-1->from,to->to+1四个节点。
// 在反转后，如果from-1和to+1不为空，说明不是头尾节点，把from-1->to，from->to+1。
// 反之，to = 头节点，from = null。
public class ReverseSubLinkedList {

    static class Node{
        private int value;
        private Node node;

        public Node(int value,Node node){
            this.value = value;
            this.node = node;
        }

        public int getValue() {
            return value;
        }

        public void setValue(int value) {
            this.value = value;
        }

        public Node getNode() {
            return node;
        }

        public void setNode(Node node){
            this.node = node;
        }
    }

    public void reverseSubLinkedList(Node head,int leftNode,int rightNode){
        Node node = head;
        Node pre = null;
        Node next = null;
        int index = 0;
        Node startNode = null;
        Node startNextNode = null;
        Node endLastNode = null;
        Node endNode = null;
        while(head != null){
            index++;
            if(index == leftNode - 1){
                startNode = head;
            }else if(index == rightNode + 1){
                endNode = head;
            }else if(index == leftNode){
                startNextNode = head;
            }else if(index == rightNode){
                endLastNode = head;
            }
            if(index >= leftNode && index <= rightNode){
                next = head.getNode();
                head.setNode(pre);
                pre = head;
                head = next;
            }else{
                head = head.getNode();
            }
        }
        if(startNode != null){
            startNode.setNode(endLastNode);
        }else{
            node = endLastNode;
        }
        if(endNode != null){
            startNextNode.setNode(endNode);
        }else{
            startNextNode.setNode(null);
        }
        StringBuilder sb = new StringBuilder();
        while(node != null){
            sb.append(node.getValue()).append(" ");
            node = node.getNode();
        }
        System.out.print(sb);
    }

    public static void main(String[] args)throws IOException {
        BufferedReader scanner = new BufferedReader(new InputStreamReader(System.in));
        int len = Integer.parseInt(scanner.readLine());
        String[] numbers = scanner.readLine().split(" ");
        Node node = null;
        for(int i = len - 1;i >= 0;i--){
            node = new Node(Integer.parseInt(numbers[i]),node);
        }
        String[] values = scanner.readLine().split(" ");
        new ReverseSubLinkedList().reverseSubLinkedList(node,Integer.parseInt(values[0]),Integer.parseInt(values[1]));
    }
}
